package com.cn.demo1;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

public class ClassLoaderDemo3 {
    public static void main(String[] args) throws IOException {
        //test1();
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        InputStream inputStream = systemClassLoader.getResourceAsStream("prop.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
        System.out.println(properties);
        if(inputStream != null){
            inputStream.close();
        }
    }

    private static void test1() throws IOException {
        Class<Student> studentClass = Student.class;
        ClassLoader classLoader = studentClass.getClassLoader();
        InputStream inputStream = classLoader.getResourceAsStream("prop.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
        System.out.println(properties);
        if(inputStream != null){
            inputStream.close();
        }
    }
}
